package user

import (
	"common/mildware"
	"common/router"
	"github.com/gin-gonic/gin"
	"project/pkg/dao/mysql"
	"project/pkg/dao/redis"
)

type URouter struct {
}
type UHandler struct {
	M mysql.Mysql
	R redis.Redis
}

func init() {
	router.AddRouter(new(URouter))
}
func NewUserHandler() UHandler {
	return UHandler{
		M: mysql.NewMysql(),
		R: redis.NewRedis(),
	}
}
func (URouter) Router(e *gin.Engine) {
	handler := NewUserHandler()
	user := e.Group("user")
	user.POST("/login", handler.Login)
	user.POST("/register", handler.Register)
	user.GET("/like/nickName", handler.LikeNickName)
	user.GET("/like/username", handler.LikeUserName)
	user.GET("info/user_id", handler.UserInfoByUserID)
	user.GET("info/id", handler.UserInfoByID)
	user.POST("group/del", handler.ExitGroup)
	user.Use(mildware.JWTAuthMiddleware())
	user.GET("/user_info", handler.GetUserInfo)
	user.POST("/update", handler.UpdateUserInfo)
	user.GET("/friends", handler.GetAllFriend)
	user.POST("/friends/add", handler.AddFriends)
	user.POST("/img/add", handler.AddImagToUser)

}
